#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int num[MAXN];
int f[MAXN];
int ans;
int main()
{
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d", &num[i]);
    for(int i = 0; i <= n; i++)
    {
        for(int j = 1; j < i; j++)
        {
            if(num[i] > num[j]) 
            {
                f[i] = f[j] + 1;
            }
            else if(num[j] > num[i]) 
            {
                f[i] = f[j];
            }
        }
        ans = max(ans, f[i]);
    }
    printf("%d", n - ans);
    return 0;
}